const units = [1000000000, 1000000, 10000];

const unitsMap = ['b', '百万', '万'];

export const formatBigNum = (num) => {
  for (let i = 0, l = units.length; i < l; i++) {
    if (num >= units[i]) {
      return {
        num: (num / units[i]).toFixed(1),
        unit: unitsMap[i],
      };
    }
  }

  return {num, unit:''};
};

export const formatTag = (item, index, type) => {
  let tagObj = {}
  switch (type) {
    case 'rank':
      tagObj.isShow = index <= 2 
      tagObj.desc = index <= 2 ? `TOP ${index+1}` : null
      break;
    default:
      break;
  }
  
  return tagObj;
};